package de.koller.enc.render;

import de.koller.oceanFramework.gl.util.ParticleTexture;
import org.lwjgl.opengl.GL11;

public class Grid {

	private final ParticleTexture grid;

	public Grid() {
		ParticleTexture.MAG_FILTER = GL11.GL_NEAREST;
		ParticleTexture.MIN_FILTER = GL11.GL_NEAREST;
		grid = ParticleTexture.generate( 32, 32 );
		
		grid.clear( 0xff0a3500 );
		for( int i = 0; i < 32; i++ ) {
			grid.setPixel( 0xff177700, i, 0 );
			grid.setPixel( 0xff177700, i, 31 );
			grid.setPixel( 0xff177700, 0, i );
			grid.setPixel( 0xff177700, 31, i );
		}
		grid.flush();
	}
	
	public void draw( Camera camera ) {
		float x = camera.getcx() % camera.getScale() - 32;
		float y = camera.getcy() % camera.getScale() - 32;
		GL11.glTexParameteri( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT );
		GL11.glTexParameteri( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT );
		grid.draw2D( x, y, 864, 672, 0, 0, 0, 27, 21 );
	}
	
}
